<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Eyes;

use Think\Log;

class Eyes extends \Service\Common\BaseModel
{
    protected $name = 'Eyes';
    //批量删除
    public function articlesDel($ids)
    {
        $array = explode(',',$ids);
        try {
            $this->startTrans();
            foreach ($array as $id) {
                M('eyes_article')->delete($id);
            }
            $this->commit();
        } catch (\Exception $e) {
            $this->rollback();
            throw new \Exception($e->getMessage());
        }
    }

    public function diseaseDel($ids)
    {
        $array = explode(',',$ids);
        try {
            $this->startTrans();
            foreach ($array as $id) {
                M('eyes_disease')->delete($id);
            }
            $this->commit();
        } catch (\Exception $e) {
            $this->rollback();
            throw new \Exception($e->getMessage());
        }
    }

    public function diseasetypeDel($ids)
    {
        $array = explode(',',$ids);
        try {
            $this->startTrans();
            foreach ($array as $id) {
                M('eyes_disease_type')->delete($id);
            }
            $this->commit();
        } catch (\Exception $e) {
            $this->rollback();
            throw new \Exception($e->getMessage());
        }
    }

    //直播列表
    public function lists($uid, $page_num, $page_size)
    {
        $where = [
            'status' => 1,
        ];
        $list = (array)M('eyes_live')->where($where)->order('px desc,id desc')->page($page_num, $page_size)->select();
        $count = M('eyes_live')->where($where)->count();
        return [
            $list,
            $page_count = $count,
            $page_total = ceil($count / $page_size),
        ];
    }




}